#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    while (n--)
    {
        int num = 0;
        cin >> num;
        vector<int> j, o;

        while (num)
        {
            if ((num % 10) % 2 == 0)
            {
                o.push_back(num % 10);
            }
            else {
                j.push_back(num % 10);
            }
            num /= 10;
        }

        if (o.size() < 1)
        {
            cout << -1 << endl;
        }
        else {
            for (auto e : j)
                cout << e;
            for (auto e : o)
                cout << e;
            cout << endl;
        }
    }
    return 0;
}